<script>
	var doupdate='__URL__/doupdate';
	var dolinkage='__URL__/dolinkage';
	var obj=new Object();
	var addormdf="{$id}";
	obj["{$lowmdmk}"+"id"]="{$id}";
</script>

<!--wangedit-->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/etc/wangEditor-2.1.22/dist/css/wangEditor.min.css">
<!--wangedit-->

<!--table部分-->
<div class='col-md-12' style='padding-top: 20px'>
	<!--开始-->
	<table class='table table-hover table-striped table-bordered'>
		<tbody>
			<?php foreach($para as $k=>$v){
					if(!in_array($k, $no_update)){
			 ?>
			
			<?php if($k=='zsxmquanjietu'){ ?>
			<!-- pt start -->
			<link rel="stylesheet" type="text/css" href="__PUBLIC__/etc/huploadify/html5uploader.css"/>
			<script type="text/javascript" src="__PUBLIC__/etc/huploadify/jquery.html5uploader.js"></script>
			<script>var dogivetail='__APP__/Hupldf/dogivetail'</script>
			<script type="text/javascript">
			$(function(){
				$('#upload').html5uploader({
					fileTypeExts:'image/jpeg,image/png',
					auto:true,
					multi:false,
					removeTimeout:0,
					url:'__APP__/Hupldf/upload/folder/zsxmquanjietu',//
					onUploadStart:function(){
						//alert('开始上传');
						var timestamp = (new Date()).valueOf();
					},
					onInit:function(){
						//alert('初始化');
					},
					onUploadComplete:function(file){
						//alert('上传完成');
						$.post(
							'__APP__/Hupldf/showphoto',
							{},
							function(data){
								$('#imgg').attr('src',data.myfl);
								$('input[name=pt]').val(data.myfl);
							},
							'json'
						);
					}
				});
			});
			</script>
			<tr><td>{$v}</td><td><div><img <?php if($mo['zsxmquanjietu']){ ?>src="{$mo['zsxmquanjietu']}" <?php }else{ ?>src='/{$project}/Public/img/atccv/default.jpg'<?php } ?> class='thumbnail' style='max-width: 100%' id='imgg' /><input type='hidden' id='zsxmquanjietu' name='pt' value="{$mo['zsxmquanjietu']}"/></div>
			<div id="upload"></div></td></tr>
		    <!-- pt over -->
		    <?php continue;} ?>

			<?php if($k=='zsxmtm'){ ?>
			<script language="javascript" type="text/javascript" src="__PUBLIC__/etc/DatePicker/My97DatePicker/WdatePicker.js"></script>
			<tr><td>{$v}</td><td><input class='form-control' id='zsxmtm' onclick="WdatePicker()"  readonly value='{$mo[zsxmtm]}' style='cursor:pointer' ></td></tr>
			<?php continue;} ?>

			
			<?php if($k=='zsxmwa'){ ?>
				<tr><td>{$v}</td><td>
					<script type="text/javascript">var project="{$project}";</script>
					<link rel="stylesheet" href="__PUBLIC__/etc/ueditor/themes/default/ueditor.css"/>
					<script type="text/javascript" src="__PUBLIC__/etc/ueditor/editor_config.js"></script>
					<script type="text/javascript" src="__PUBLIC__/etc/ueditor/editor_all.js"></script>
					<div>
					
					  <div id="myEditor">
						<script type="text/javascript">
							var editor = new baidu.editor.ui.Editor({
							    initialContent: '{$moforjs.zsxmwa}'
							});
							editor.render("myEditor");
						</script>
						</div>
					</div>
					<textarea id='zsxmwa' style='display:none'></textarea>
				</td></tr>
			<?php continue;} ?>

			<tr><td>{$v}</td><td>
			<?php if(strstr($k, '_')){ ?>
			<select id='{$k}'>
				<option value='0'>无</option>
				<?php //处理萃取下主题
                  $tmp=explode('_', $k);$tmp=explode('id',$tmp[2]);$tmp=$tmp[0];
                ?>
				<volist name='$k' id='v'><option value="<?php echo $v[$tmp.'id'] ?>"><?php echo $v[$tmp.'nm'] ?></option></volist>
			</select>
			<?php }else if(isset($transmean[$k])){ ?>
			<select id='{$k}'>
				<?php foreach($transmean[$k] as $v=>$dsc){ ?>
				<option value="{$v}">{$dsc}</option>
				<?php } ?>
			</select>
			<?php }else{ ?>
			<input class='form-control'  id='{$k}'>
			<?php } ?>
			<script>var k="{$k}";var v="{$moforjs[$k]}";if(k.indexOf('_')!=-1&&v==''){$('#'+k).val('0');}else{$('#'+k).val(v);}</script>
			</td></tr>
			<?php }
			} ?>
		</tbody>
	</table>
	<br>
	<a class='btn btn-primary' id='update_fake'><?php if($id==0){ ?>添加<?php }else{ ?>修改<?php } ?></a>
	
</div>

<script>
//自身参数，初始数据
var para=new Object();
var selfpara=new Array();
var origindata=new Object();

<?php 
foreach($para as $k=>$v){ 
	if(!in_array($k, $notself)){
?>
para["{$k}"]="{$v}";
selfpara.push("{$k}");
origindata["{$k}"]="{$moforjs[$k]}";
<?php 
	}
} 
?>

//不用管的，也不用显示的
var no_update=new Array();
<?php 
foreach($no_update as $nuv){ 
?>
no_update.push("{$nuv}");
<?php 
} 
?>
//zabojin的属性里面在显示中，允许空的
var allowempty=new Array();
<?php 
foreach($allowempty as $aev){ 
?>
allowempty.push("{$aev}");
<?php 
} 
?>
//transmean
var transmeank=new Array();
<?php 
foreach($transmean as $tmvk=>$tmvv){ 
?>
transmeank.push("{$tmvk}");
<?php 
} 
?>



//#########
$(function(){

	$('#update_fake').click(function(){

		$('#zsxmwa').val(editor.getContent());		
		//然后判断哪些是有变动的，变动的数值需要提交修改，没有变动的则直接不用接后台了
		//其中添加需要全盘给上，修改只用给变量就行
		if(addormdf!=0){
			var str='';
			for(var i=1;i<selfpara.length;i++){
				//排除掉不用管的
				var key=selfpara[i];var tmp=$('#'+key);var valuenow=$.trim(tmp.val());
				
				if(no_update.indexOf(key)==-1){
					if(valuenow!=origindata[key]){
						str=str+'['+para[key]+']'+origindata[key]+'=>'+valuenow+'<br>';
					}
				}
			}
			var bz1ctt=str;
		}else{
			var bz1ctt='创建';
		}
		if(bz1ctt==''){ msg('修改内容不能为空');return; }
		$('#bz1').html(bz1ctt);

		$('#beizhu').trigger('click');
	})


	$('#update').click(function(){

		//首先把相关的参数数据聚集起来，把自身更新需要的参数以及变动的数据进行传输
		//由于第一个往往是id所以，就不去考虑了
		//先判断是否为空
		for(var i=1;i<selfpara.length;i++){
			var key=selfpara[i];var tmp=$('#'+key);
			//如果是允许空的，就不用考虑他有没有空的事情了；反之不在这里头，就要考虑了
			if(no_update.indexOf(key)==-1&&allowempty.indexOf(key)==-1){var tagname=tmp.get(0).tagName;
				if(tagname=='INPUT'&&$.trim(tmp.val())==''){
					msg(para[key]+'不能为空');tmp.focus();return;
				}else if(transmeank.indexOf(key)==-1&&tagname=='SELECT'&&$.trim(tmp.val())=='0'){
					msg(para[key]+'未选择');tmp.focus();return;
				}
			}
			
		}
		//然后判断哪些是有变动的，变动的数值需要提交修改，没有变动的则直接不用接后台了
		//其中添加需要全盘给上，修改只用给变量就行
		if(addormdf!=0){
			var flag_change=0;
			for(var i=1;i<selfpara.length;i++){
				//排除掉不用管的
				var key=selfpara[i];var tmp=$('#'+key);var valuenow=$.trim(tmp.val());
				
				if(no_update.indexOf(key)==-1){
					if(valuenow!=origindata[key]){
						flag_change=1;
						obj[key]=valuenow;
					}
				}
			}
			if(flag_change==0){msg('没有任何信息改变');return;}
		}else{
			for(var i=1;i<selfpara.length;i++){
				var key=selfpara[i];var tmp=$('#'+key);var valuenow=$.trim(tmp.val());
				if(no_update.indexOf(key)==-1){
					obj[key]=valuenow;
				}
			}
		}

		obj['beizhu']=$('#bz1').html()+'<br>'+editor_bz2.$txt.html();

		$.post(
			doupdate,
			obj,
			function(data){
				
				var str='';
            	if(data['pattern']=='0'){str='添加';}else{str='修改';}
            	msg(str+'成功！点击返回',2);
            	
                console.log("success");
			
			
			},
			'json'
		);
	})
})
</script>

<script>

$(function(){
  //记录
  var ipf=new Array();
  <?php foreach($impactfactor as $ifv){ ?>
    ipf.push("{$ifv}");
  <?php } ?>
  <?php foreach($impactfactor as $ifv){ ?>
    $('#'+"{$ifv}").change(function(){
      var obj=new Object();
      obj['trigger']="{$ifv}";
      for(var i=0;i<ipf.length;i++){
        obj[ipf[i]]=$('#'+ipf[i]).val();
      }
      $.ajax({
          'type': 'GET',
          'url':dolinkage,
          'async':false,  
          'contentType': 'application/json',
          'data': obj,
          'dataType': 'json',
          'success': function(data) {
            for(var i=0;i<data.length;i++){
              var aim=data[i]['aim'];
              var str="<option value='0'>无</option>";
              if(data[i]['ls']){
	              for(var j=0;j<data[i]['ls'].length;j++){
	                str=str+"<option value='"+data[i]['ls'][j][data[i]['prex']+'id']+"'>"+data[i]['ls'][j][data[i]['prex']+'nm']+"</option>"
	              }
	          }
              $('#'+aim).html(str);
            }
          },
          'error':function() {
            console.log("error");
          }
      });
    })
  <?php } ?>
})

</script>


<!--#################-->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal_beizhu" style='display: none' id='beizhu'>
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal" id="myModal_beizhu" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog" style='padding-top:100px'>
    <div class="modal-content">
      <div class="modal-header">
      <button type="button" class="close close_beizhu" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <h4 class="modal-title">备注</h4>
    </div>
      <div class="modal-body">
      	<div>变动项目&备注选填：</div>
      	<div class='col-md-12' style="background-color:#ddd;color:#888;font-size:11px;padding:5px" id='bz1'></div>
        <div class="clearfix"></div>
        <div  id='editor-bz2'></div>
        <a class='btn btn-success' id='update'><?php if($id==0){ ?>添加<?php }else{ ?>修改<?php } ?></a>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default close_beizhu" data-dismiss="modal" >关闭</button>
        
      </div>
    </div>
  </div>
</div>

<!--wangedit-->
<script type="text/javascript" src="__PUBLIC__/etc/wangEditor-2.1.22/dist/js/wangEditor.js"></script>
<script type="text/javascript">
var editor_bz2=new wangEditor('editor-bz2');
// 普通的自定义菜单
editor_bz2.config.menus = [
    'source',
    '|',     // '|' 是菜单组的分割线
    'bold',
    'underline',
    'italic',
    'strikethrough',
    'eraser',
    'forecolor',
    'bgcolor'
 ];
editor_bz2.create();
</script>
<!--wangedit-->